package com.longge;

public class KthSmallest {

    int num = 0;
    int ans = 0;


    public int kthSmallest(TreeNode root, int k) {
        if (root == null) return -1;
        kthSmallest(root.left, k);
        num++;
        if (num == k) {
            ans = root.val;
        }
        kthSmallest(root.right, k);
        return ans;

    }

}
